<?php

use Biz\model\brand\Brand;

class BrandAccountAction extends ActionPlugin
{
    const USER_LEVEL = self::LEVEL_NOTHING;

    public function main()
    {
        $data = [];
        $uid = $this->getRequest()->getPost('uid', 0);
        $accountList = $uid ? \Biz\service\brandAccount\BrandAccount::getAllByUid($uid) : [];
        $account = current($accountList);
        if ($account) {
            $result['account'] = $account;
            $brand_info = $account['brand_id'] ? Brand::getBrandInfoById($account['brand_id']) : [];
            $result['account']['descrip'] = empty($brand_info) ? '' : $brand_info['detail'];
            $shop = \Biz\service\brandAccount\BrandAccount::getShopInfos($account['id']);
            $result['shop'] = $shop;
        } else {
            $result['shop'] = [];
        }

        $this->setSuccess($result);

    }
}